package com.qdu.controller;


import com.qdu.commons.Result;
import com.qdu.entity.Problem;
import com.qdu.entity.User;
import com.qdu.service.IProblemService;
import com.qdu.service.impl.ProblemServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ellery2018
 * @since 2022-03-09
 */
@RestController
@RequestMapping("/problem")
@Api(value = "答题模块")
public class ProblemController {

    @Autowired
    ProblemServiceImpl problemService;

    @PostMapping("/findall")
    @ApiOperation(value = "查找题目列表")
    public List<Problem> findAllProblem() {
        List list = problemService.findAllProblem();
        System.out.println(list);
        return list;
    }

    @PostMapping("/insert")
    @ApiOperation(value = "插入题目")
    public int insertProblem(@RequestBody Problem problem) {
        return problemService.insertProblem(problem);
    }

    @PostMapping("/delete")
    @ApiOperation(value = "删除题目")
    public int deleteProblem(@RequestParam("id") Integer id) {
        return problemService.deleteProblem(id);
    }

    @PostMapping("/update")
    @ApiOperation(value = "编辑题目")
    public int updateProblem(@RequestBody Problem problem) {
        return problemService.updateProblem(problem);
    }
}
